<template>
  <div>
    <div id="piemain" style="width: 600px; height: 400px"></div>
  </div>
</template>
<script>
export default {
  props: {
    pieData: {}
  },
  mounted () {
    this.pieInit()
  },
  watch: {
    pieData () {
      this.pieInit()
    }
  },
  methods: {
    pieInit () {
      var pieChart = this.$echarts.init(document.getElementById('piemain'))
      const option = {
        title: {
          text: '人员统计',
          subtext: '每天8点更新',
          left: 'center'
        },

        tooltip: {
          trigger: 'item',
          formatter: '<span style="color:red;">{a}</span> </br>{b}</br>{c}%'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '提示',
            type: 'pie',
            radius: '50%',
            data: this.pieData,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      pieChart.setOption(option)
    }
  }
}
</script>
